package classes.fire {
	import flash.display.MovieClip;
	import flash.events.*;

	import classes.GameSetting;

	/**
	 * ...
	 * @author fox
	 */
	public class Shooter extends MovieClip {
		
		private var _angle:Number;

		public function Shooter(){
		}

		public function initShooter():void {
			this.barrel.rotation = 180;
			stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
		}
		
		public function clearAll():void {
			stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
		}

		private function mouseMoveHandler(e:MouseEvent):void {
			var _tmpRotation = -(Math.atan2((this.y - stage.mouseY), (stage.mouseX - this.x)) * 180 / Math.PI - 90);
			if (_tmpRotation > GameSetting.angle && _tmpRotation < (360 - GameSetting.angle)){
				_angle = _tmpRotation - 90;
				//trace("_angle="+_angle);
				this.barrel.rotation = _tmpRotation;
			}
		}
		
		public function set angle(_val:Number):void {
			_angle = _val;			
		}
		
		public function get angle():Number {
			return _angle;
		}
	/***********************************************************************************************/
	}
}